package com.wingsoft.homeFlow.bo;

import com.wingsoft.common.enums.SwitchEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

@Data
public class HomeFlowTaskVarVo {

    @ApiModelProperty("ID")
    private String id;

    @ApiModelProperty("任务编码")
    private String taskCode;

    @ApiModelProperty("步骤KEY")
    private String stepCode;

    @ApiModelProperty("变量编码")
    private String varCode;

    @ApiModelProperty("变量名称")
    private String varName;

    @ApiModelProperty("变量完整名")
    public String getVarCodeFull() {
        return StringUtils.isNotBlank(stepCode) ? (stepCode + "_" + varCode) : varCode;
    }

    @ApiModelProperty("变量取值路径")
    private String varPath;

    @ApiModelProperty("数据类型：1-单个；2-对象；3-集合；4-日期")
    private Integer dataType;

    @ApiModelProperty("默认值")
    private String defaultValue;

    @ApiModelProperty("是否全局：1-是 0-否")
    private Integer globalFlag;

    @ApiModelProperty("是否工作流参数：1-是 0-否")
    private Integer flowFlag;

    @ApiModelProperty("是否手动添加：1-是 0-否")
    private Integer manualFlag;

    @ApiModelProperty("参数顺序")
    private Integer varIndex;

    @ApiModelProperty("来源")
    public String getSourceDesc() {
        if (Objects.equals(flowFlag, SwitchEnum.TRUE.getCode())) {
            return "流水线参数";
        } else if (Objects.equals(manualFlag, SwitchEnum.TRUE.getCode())) {
            return stepCode + "手动添加";
        } else {
            return stepCode + "参数解析";
        }
    }

}